package io.jpress.utils;

import java.util.UUID;

public class UUIDUtils {
	/**
	 * 生成10位UUID
	 * 
	 * @return
	 */
	public static String getID10() {
		UUID uuid = UUID.randomUUID();

		// 改变uuid的生成规则
		return HashUtils.convertToHashStr(uuid.getMostSignificantBits(), 5)
				+ HashUtils.convertToHashStr(uuid.getLeastSignificantBits(), 5);
	}
	/**
	 * 生成36位UUID
	 */
	public static String getID36(){
		return UUID.randomUUID().toString();
	}
	/**
	 * 生成32位UUID
	 * @return
	 */
	public static String getID32(){
		return UUID.randomUUID().toString().replaceAll("-", "");
	}

	/**
	 * 转换目前32位UUID为10位UUID
	 * 
	 * @param uuidStr
	 * @return
	 */
	public static String convertID(String uuidStr) {
		UUID uuid = UUID.fromString(uuidStr);
		// 改变uuid的生成规则
		return HashUtils.convertToHashStr(uuid.getMostSignificantBits(), 5)
				+ HashUtils.convertToHashStr(uuid.getLeastSignificantBits(), 5);
	}
	
	
	public static void main(String[] args) {
		System.out.println(getID32());  
	}

}
